/*
 * Copyright 2008 Andrej Herich
 * 
 * http://azetclient.yw.sk/
 * http://azetclient.googlecode.com/
 * 
 * This file is part of AzetClient.
 * 
 * AzetClient is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * AzetClient is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with AzetClient.  If not, see <http://www.gnu.org/licenses/>.
 */

package sk.yw.azetclient.gui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.KeyStroke;
import org.apache.log4j.Logger;
import sk.yw.azetclient.Main;

/**
 *
 * @author error216
 */
public class ExitAction extends AbstractAction {
    
    private static final long serialVersionUID = 2456345258l;
    
    private static final Logger logger = Logger.getLogger(ExitAction.class);
    
    public ExitAction() {
        super(Main.getText("action.exit"));
        
        putValue(AbstractAction.ACCELERATOR_KEY,
                KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK));
    }

    public void actionPerformed(ActionEvent e) {
        Main.getMainFrame().stop();
        
        // next statement should be unnecesary, because properties should be
        // saved directly after they are changed
        Main.saveProperties();
        
	logger.info("End");
        System.exit(0);
    }

}
